﻿//
// Copyright (c) 2024 BPer
//
#ifndef SRC_BPERCAPTURE_SRC_WIN_BPERWINAUDIOAPI_H_
#define SRC_BPERCAPTURE_SRC_WIN_BPERWINAUDIOAPI_H_
#include <bperaudiodev/win/BPerWinAudioApiCapture.h>
#include <bperaudiodev/win/BPerWinAudioApiRender.h>
#include <bperaudiodev/BPerCaptureCallback.h>
#include <bperaudiodev/BPerAudioCapture.h>

#include <bperutil/buffer/BPerAudioPlayBuffer.h>
#include <bperavutil/audio/BPerPreProcess.h>
#include <bperavutil/audio/BPerAudioMix.h>
#include <bperutil/sys/BPerLoadLib.h>
#include <vector>

#if BPer_OS_WIN
#include "bperWinAudioCaptureHandle.h"

class BPerWinAudioApiDevice: public BPerAudioCapture,public BPerCaptureCallback {
public:
    BPerWinAudioApiDevice(BPerContext *pcontext,bool isRecord,bool usingBuiltinAec=false);
	 ~BPerWinAudioApiDevice();
	int init();
	void setInAudioBuffer(std::vector<BPerAudioPlayBuffer*> *pal);
	void setPreProcess(BPerPreProcess *pp);
	void setCatureStart();
	void setCatureStop();
	void setOutAudioBuffer(BPerAudioBuffer *pbuffer);
	void setPlayAudoBuffer(BPerAudioBuffer *pbuffer);
	void setAec(BPerRtcAec *paec);
	void caputureAudioData(BPerFrame* audioFrame);
	BPerAudioCaptureHandle *m_ahandle;

protected:
	void startLoop();
	void stopLoop();

private:
    int m_loops;
	int m_isInit;
	int m_outLen;


private:
	bool m_usingBuiltinAec;
	BPerAudioApiCapture *m_capture;
    BPerWinAudioApiRender* m_player;
};

#endif /* SRC_BPERCAPTURE_SRC_WIN_BPERWINAUDIOAPI_H_ */
#endif
